import {
	CmdToolbox,
	CoreReg,
	Internal,
	MCU_Core
} from "./structs.slint";
import { UiIo } from "global.slint";
import { TestData } from "test-data.slint";
import { ComboBox, Button, HorizontalBox } from "std-widgets.slint";

export component ToolBox inherits HorizontalBox {
	padding-bottom: 0;
	padding: 3px;
	Text {
		Rectangle {
			border-color: gray;
			border-width: 0.8px;
			border-radius: 6px;
		}
		text: " Home \n Page";
		font-size: 10px;
		vertical-alignment: center;
		TouchArea { clicked => { UiIo.open-url("https://gitee.com/merisy/mcu-debug-probe"); } }
	}

	Button {
		text: "Reflash";
		clicked => { UiIo.probe-toolbox(CmdToolbox.Reflash); }
	}
	ComboBox {
		horizontal-stretch: 0;
		model: UiIo.probe_list;
		selected(id) => { UiIo.selected_probe = id; }
	}
	ComboBox {
		horizontal-stretch: 0;
		model: UiIo.core_list;
		selected(id) => { UiIo.selected_core = id; }
	}
	Button {
		text: UiIo.attach_state ? "Deattach" : "Attach";
		clicked => { UiIo.probe-toolbox(CmdToolbox.Attach); }
	}
	Button {
		text: "Reset";
		clicked => { UiIo.probe-toolbox(CmdToolbox.Reset); }
	}
	Button {
		text: "Halt";
		clicked => { UiIo.probe-toolbox(CmdToolbox.Halt); }
	}
	Button {
		text: "Run";
		clicked => { UiIo.probe-toolbox(CmdToolbox.Run); }
	}
	Button {
		text: "Step";
		clicked => { UiIo.probe-toolbox(CmdToolbox.Step); }
	}
	Button {
		visible: false;
		enabled: UiIo.debug_info_valid;
		text: "StepInto";
		clicked => { UiIo.probe-toolbox(CmdToolbox.StepInto); }
	}
	Button {
		visible: false;
		enabled: UiIo.debug_info_valid;
		text: "StepOver";
		clicked => { UiIo.probe-toolbox(CmdToolbox.StepOver); }
	}
	Button {
		visible: false;
		enabled: UiIo.debug_info_valid;
		text: "StepOut";
		clicked => { UiIo.probe-toolbox(CmdToolbox.StepOut); }
	}
	Button {
		visible: false;
		text: "Load ELF";
		clicked => { UiIo.probe-toolbox(CmdToolbox.LoadELF); }
	}
	Rectangle {  }
}